﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SDK10kWrapper;

namespace TestUI
{
    public partial class CamControl4Test : Form
    {
        public CamControl4Test()
        {
            InitializeComponent();
        }

        private void CamControl4Test_Load(object sender, EventArgs e)
        {
        }

        private void butPlay_Click(object sender, EventArgs e)
        {
            cameraBox1.Offline_VideoPlayPath = tbPlay1.Text;
            cameraBox2.Offline_VideoPlayPath = tbPlay2.Text;
            cameraBox3.Offline_VideoPlayPath = tbPlay3.Text;
            cameraBox4.Offline_VideoPlayPath = tbPlay4.Text;
            CameraBox.PlayAll(this);
        }

        private void butPause_Click(object sender, EventArgs e)
        {
            CameraBox.PauseAll(this);
        }

        private void butStop_Click(object sender, EventArgs e)
        {
            CameraBox.StopAll(this);
        }

        private void butRecord_Click(object sender, EventArgs e)
        {
            CameraBox.StartRecordAll(this);
        }

        private void butStopRec_Click(object sender, EventArgs e)
        {
            System.IO.FileInfo finfo = cameraBox1.StopRecord();
            if (finfo != null)
            {
                MessageBox.Show("Successfull record to this file :\r\n    " + finfo.FullName, cameraBox1.Name);
            }

            /*finfo = cameraBox2.StopRecord();
            if (finfo != null)
            {
                MessageBox.Show("Successfull record to this file :\r\n    " + finfo.FullName, cameraBox2.Name);
            }*/
        }

        private void butRec2Folder_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Not implement yet ! This is static call for all cameraBox instance", "Implement soon !");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            cameraBox1.Capture(tbCapture.Text);
            //cameraBox2.CaptureFrame(tbCapture.Text);
            //cameraBox3.CaptureFrame(tbCapture.Text);
            //cameraBox4.CaptureFrame(tbCapture.Text);
        }

        private void radOffline_CheckedChanged(object sender, EventArgs e)
        {
            if (radOffline.Checked)
            { 
                CameraBox.ChangeModeAll(this, CameraMode.Offline);
                gbOffline.Enabled = true; gbOnline.Enabled = false;
            }
        }

        private void radOnline_CheckedChanged(object sender, EventArgs e)
        {
            if (radOnline.Checked)
            {
                CameraBox.ChangeModeAll(this, CameraMode.Online);
                gbOffline.Enabled = false; gbOnline.Enabled = true;
            }
        }

        private void butBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Media Files|*.avi;*.asf;*.wmv;*.flv;*mkv"; ofd.Multiselect = true;
            DialogResult res = ofd.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                if (ofd.FileNames.Length < 4) { MessageBox.Show("Please choose at least 4 movie file"); return; }
                tbPlay1.Text = ofd.FileNames[0];
                tbPlay2.Text = ofd.FileNames[1];
                tbPlay3.Text = ofd.FileNames[2];
                tbPlay4.Text = ofd.FileNames[3];
            }
        }

        private void CamControl4Test_FormClosed(object sender, FormClosedEventArgs e)
        {

        }
    }
}